﻿using durable.xml.ConfigProvider;
using Durable.DControl;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Durable
{
    public partial class Form1 : Form
    {
        XmlProvider xml = new XmlProvider();
        string configpath = string.Empty;
        string CustomCheckInfopath = string.Empty;
        Dictionary<string, string> listConfig = new Dictionary<string, string>();
        FrameControl frameControl = new FrameControl();
        DataGridControl dataGridControl = new DataGridControl();
        WaveControl waveControl = new WaveControl();
        public Form1()
        {
            InitializeComponent();
            configpath = AppDomain.CurrentDomain.BaseDirectory + "/Config/Config.xml"; ;
            CustomCheckInfopath = AppDomain.CurrentDomain.BaseDirectory + "/Config/CustomCheckInfo.xml"; ;
        }
       
        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (this.tabControl1.SelectedIndex)
            {
                case 0:
                    break;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            #region 初始化数据
            Combo1.Items.Add("15");
            Combo1.Items.Add("20");
            Combo1.Items.Add("25");
            Combo1.Items.Add("32");
            Combo1.Items.Add("40");
            Combo1.Items.Add("50");

            Combo3.Items.Add("1");
            Combo3.Items.Add("2");

            Combo2.Items.Add("超声波");
            Combo2.Items.Add("机械");
            frameControl.LoadConfig(Frame5);
            dataGridControl.CustomCheckInfoData(Combo1.SelectedItem.ToString(), JDDGrid);
            frameControl.LoadControl(Frame5, Frame8);
            frameControl.OnCBBSelectedIndexChanged = (dy) =>
            {
                Box_SelectedIndexChanged(dy);
            } ;
            frameControl.OnRDCheckedChanged = (dy) =>
            {
                R_CheckedChanged(dy);

            };
            frameControl.OnTKeyUp = (dy) =>
            {
                C_KeyUp(dy);

            };
            waveControl.LoadPicone(Wave);
           
            #endregion
        }
        #region 事件操作
        private void R_CheckedChanged(object sender)
        {
            RadioButton r = (RadioButton)sender;
            if (r.Name == "Option2400H")
            {
                Combo3.Enabled = false;
                Combo2.Enabled = false;
                this.Text = "2400小时耐久性试验";
            }
            else if (r.Name == "Option500H")
            {
                Combo3.Enabled = true;
                Combo2.Enabled = false;
                this.Text = "300/500小时试验";
            }
            else if (r.Name == "Option4000ci")
            {
                Combo2.Enabled = true;
                Combo3.Enabled = false;
                this.Text = "4000次冲击循环试验";
            }
        }

        private void Box_SelectedIndexChanged(object sender)
        {
            ComboBox box = (ComboBox)sender;
            if (box.Tag.ToString() == "Caliber")
            {
                dataGridControl.CustomCheckInfoData(box.SelectedItem.ToString(), JDDGrid);

            }           
        }

        private void C_KeyUp(object sender)
        {
         
        }

        #endregion
        private void Command8_Click(object sender, EventArgs e)
        {
            test test = new test();
            test.ShowDialog();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            waveControl.draw(Wave);
        }
    }
}
